<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../base.jsp" %>
<style>
	.content-wrapper{margin-left: 0px}
</style>
<body class="hold-transition skin-blue sidebar-mini">

	<div class="wrapper">
		<!-- Content Wrapper. Contains page content -->
		<div class="content-wrapper">
			<!-- Content Header (Page header) -->
			<section class="content-header">
				<h1>角色管理<small><c:if test="${role.id == null}">新增</c:if><c:if test="${role.id != null}">新增</c:if>角色</small></h1>
				<ol class="breadcrumb">
					<li><a href="javascript:;"><i class="fa fa-dashboard"></i> 首页</a></li>
					<li class="active"><c:if test="${role.id == null}">新增</c:if><c:if test="${role.id != null}">新增</c:if>角色</li>
				</ol>
			</section>
			<!-- Main content -->
			<section class="content">
	            <!-- form start -->
				<form id="saveForm">
				<div class="row">
					<div class="col-md-12">
					<div class="box box-info">
			            <div class="box-header with-border">
			              <h3 class="box-title">角色信息 </h3>
			            </div>
			            <!-- /.box-header -->
			              <div class="box-body form-horizontal">
			               <div class="form-group">
			                 <label for="inputEmail3" class="col-sm-2 control-label">角色名称</label>
			                 <div class="col-sm-3">
			                   <input type="text" class="form-control" name="roleName" id="roleName" value="${role.roleName }">
			                 </div>
			               </div>
			               <div class="form-group">
			                 <label for="inputEmail3" class="col-sm-2 control-label">备注</label>
			                 <div class="col-sm-3">
			                   <input type="text" class="form-control" name="remark" value="${role.remark }">
			                 </div>
			               </div>
			               
			               <div class="box-footer">
			                <a class="btn btn-info save">保存</a>
			                <a class="btn btn-default cancel" >取消</a>
			             </div>
			          </div>
			        </div>
				</form>
			</section>
		</div>
	</div>
	<script type="text/javascript">
	$(function () {
		$('.cancel').on('click',function(){
			location.href = path+'permission/role/list';
		});
		$('.save').on('click',function(){
			var roleName = $('#roleName').val();
			if(!roleName){
				layer.msg("请填写角色名称！");return;
			}
			$.ajax({
				type: "post", 
	            url: path+"permission/role/merge",
	            data:$('#saveForm').serialize(),
	            dataType: "json",
	            success: function(data){
	            	if(data > 0){
	            		layer.msg('保存成功', {
                		  closeBtn: 0
                		}, function(){
                			location.href = path+'permission/role/list';
                		});
	            	}else{
	            		alert('保存失败！');
	            	}
	            }
			});
		});
	});
	</script>
</body>